//
//  Worker+SendCode.swift
//  Auto114
//
//  Created by yangbin on 2020/9/6.
//  Copyright © 2020 RMCtl. All rights reserved.
//

import Foundation
import Alamofire

extension Worker {
    
    func preSendCode() {
        let url = baseUrl + "common/verify-code/send"
        netSession.request(url, method: .head, parameters: nil, headers: headers).responseJSON { (resp) in
            
        }
    }
    
    func sendCode(productKey: String, complete: @escaping (Bool) -> Void) {
        let url = baseUrl + "common/verify-code/send"
        getUrl(url, params: [
            "_time": ts,
            "mobile": phoneBase64,
            "smsKey": "ORDER_CODE",
            "uniqProductKey": productKey
        ]) { (resp) in
            guard let json = resp.result.any as? [String: Any],
                let resCode = json["resCode"] as? Int, resCode == 0 else {
                    complete(false)
                    return
            }
            complete(true)
        }
    }
    
}
